package small.common.designPattern.behavioral.observer.publisher;

import small.common.core.exceptions.Closeable;
import small.common.designPattern.behavioral.observer.event.Event;
import small.common.designPattern.behavioral.observer.subscriber.Subscriber;

/**
 * @author jinzhou
 * @data 2023/5/9 17:56
 */
public interface EventPublisher extends Closeable {

    /**
     * 添加订阅者
     * @param subscriber
     */
    void addSubscriber(Subscriber subscriber);

    /**
     * 移除订阅者
     * @param subscriber
     */
    void removeSubscriber(Subscriber subscriber);

    /**
     * 发布事件
     * @param event
     * @return
     */
    boolean publish(Event event);

    /**
     * 通知订阅者
     * @param subscriber
     * @param event
     */
    void notifySubscriber(Subscriber subscriber, Event event);

    /**
     * 队列长度
     * @return
     */
    long currentEventSize();
}
